package com.lkc.domain.vo;

import com.lkc.domain.entity.Menu;
import com.lkc.utils.tree.TreeUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @Title: MenuTreeVo
 * @Author 椰咩咩
 * @Package com.lkc.domain.vo
 * @Date 2022/12/24 13:30
 * @description: menu构建树形结构的视图模型
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MenuTreeVo implements TreeUtils.TreeNode<Long> {

    private Long id;
    //菜单名称
    private String menuName;
    //父级菜单ID（-1为顶级菜单）
    private Long parentId;
    //页面的title
    private String title;
    //菜单的显示顺序
    private Integer orderNum;
    //菜单的路由地址
    private String path;
    //菜单的图标
    private String icon;
    //菜单的类型（D目录，M菜单，B按钮，C组件）
    private String type;

    List<MenuTreeVo> children;

    @Override
    public Long id() {
        return id;
    }

    @Override
    public Long parentId() {
        return parentId;
    }

    @Override
    public boolean root() {
        return parentId.equals(1);
    }

    @Override
    public void setChildren(List<? extends TreeUtils.TreeNode<Long>> children) {
        this.children = (List<MenuTreeVo>) children;
    }

    @Override
    public List<? extends TreeUtils.TreeNode<Long>> getChildren() {
        return children;
    }
}
